﻿using FluentValidation;
using MediatR;
using Microsoft.Extensions.DependencyInjection;
using ShuiLing.Application.Behaviors;

namespace ShuiLing.Application;

public static class DependencyInjection
{
    public static IServiceCollection AddApplicationInject(this IServiceCollection services)
    {
        services.AddScoped(typeof(IPipelineBehavior<,>), typeof(ValidationPipelineBehavior<,>));
        services.AddValidatorsFromAssembly(
            ShuiLing.Application.AssemblyReference.Assembly,
            includeInternalTypes: true);
        services.AddMediatR(options => options.RegisterServicesFromAssembly(AssemblyReference.Assembly));
        return services;
    }
}
